<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>上海农商还款卡详情</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="ins_cfg_info_edit_form">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_50">
                        <div class="label">客户姓名</div>
                        <div class="field">
                            <span >${cstNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">身份证号</div>
                        <div class="field">
                            <span >${certNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_100">
                        <div class="label">合同号</div>
                        <div class="field">
                            <span >${lsCntNo}</span>
                        </div>
                    </div>
                    <div>
                        <div class="label" style="color: blue;">绑卡信息</div>
                    </div>

                    <div class="fieldBox col_100_auto">
                        <div id="ligergrid_bind_card" class="sq-grid"></div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    var ligergrid_bind_card;
    var queryBindFlag = '${queryBindFlag}';
    $(function () {
        let prjId = '${prjId}';
        let fundRasInsId = '${fundRasInsId}';
        initGrid(prjId,fundRasInsId);
        initData();
    });

    function initData() {
        $("#ins_cfg_info_edit_form").ligerForm({
            validate: true
        });

    }
    /**
     * 初始化绑卡信息列表
     *
     **/
    function initGrid(prjId,fundRasInsId){

        ligergrid_bind_card =  $("#ligergrid_bind_card").ligerGrid({
            method: 'get',
            url: '<%=path%>/institution/shnsbank/initCardList.do?prjId='+prjId+'&fundRasInsId='+fundRasInsId,
            columns: [
                { display: '银行账户', name: 'cardNo', minWidth: 50,align:'center',enabledSort:false},
                { display: '预留手机号', name: 'mobileNo', minWidth: 50,align:'center',enabledSort:false},
                getGridOperColumnContent(prjId)
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            frozen: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers:true,//列表是否有行号
            usePager: false //服务器分页
        });
    }

    //解绑操作
    function getGridOperColumnContent(prjId){
        var data = "";
        if(!queryBindFlag || !queryBindFlag == "true"){
            data = {
                display: '操作',
                isSort: false,
                width: 130,
                align:'left',
                render: function (rowdata, rowindex, value){
                    var j="";
                    j+='<a class="sq-button-hasicon" style="color:blue;" href="javascript:unBindCard(';
                    j+="'"+rowdata.cardNo+"',";
                    j+="'"+prjId+"'";
                    j+=')">解绑</a>';
                    return j;
                }
            }
        }
        return data;
    }

    //解绑
    function unBindCard(cardNo,prjId){
        if (null == cardNo || "" == cardNo) {
            top.$.ligerDialog.SQalert({content: "银行卡号不能为空!", SQ_type: "error"});
            return false;
        }
        if (null == prjId || "" == cardNo) {
            top.$.ligerDialog.SQalert({content: "项目id不能为空!", SQ_type: "error"});
            return false;
        }
        var wait_dialog;
        var url = '<%=path%>/institution/shnsbank/unbindCard.do';
        $.ajax({
            type:"post",
            url: url,
            data: { cardNo : cardNo,
                    prjId : prjId },
            dataType:"json",
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //不关闭当前页面,刷新父页面
                    // parent.grid.reload();
                    ligergrid_bind_card.reload();
                    UIUtils.alertSuccessHold1(msg.info);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }
</script>


</body>
</html>